﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Tasks
{
    class Program
    {
        private const string src = "V:\\Projects\\BigfootCSS\\css\\source\\";
        private const string dest = "V:\\Projects\\BigfootCSS\\css\\";
        
        static void Main(string[] args)
        {
            GenerateBigfoot_CSS();
            GenerateBigfoot_Module_Reset_CSS();
        }

        static string GetResetSource()
        {
            return File.ReadAllText(src + "Bigfoot_Source_Reset.css");
        }

        static string GetSource()
        {
            return File.ReadAllText(src + "Bigfoot_Source.css");
        }

        static void GenerateBigfoot_CSS()
        {
            var resetSource = GetResetSource();
            var source = GetSource();

            // #prefix, | #prefix { > should be replaced by body
            resetSource = resetSource.Replace("#prefix,", "body,");
            resetSource = resetSource.Replace("#prefix {", "body {");
            // Replace #prefix
            resetSource = resetSource.Replace("#prefix", "");
            source = source.Replace("#prefix", "");

            // Create Files
            File.WriteAllText(dest + "Bigfoot_Reset.css", resetSource);
            File.WriteAllText(dest + "Bigfoot_NoReset.css", source);
            File.WriteAllText(dest + "Bigfoot.css", resetSource + source);
        }

        static void GenerateBigfoot_Module_Reset_CSS()
        {
            var resetSource = GetResetSource();
            var source = GetSource();

            // Replace #prefix
            resetSource = resetSource.Replace("#prefix", "#bfbox");
            source = source.Replace("#prefix", "#bfbox");

            // Create Files
            File.WriteAllText(dest + "Bigfoot_Module_Reset.css", resetSource);
            File.WriteAllText(dest + "Bigfoot_Module_NoReset.css", source);
            File.WriteAllText(dest + "Bigfoot_Module.css", resetSource + source);
        }


    }
}
